import http from "../utils/Http";
import { TaskWork, FlowHistory } from "../model/TaskModel";

/**
 * 获取模版列表
 */
export const templateList = () => {
  return http<string[]>({
    method: 'post',
    url: '/flow/templateList'
  })
}

/**
 * 保存模版
 */
export const saveTemplate = (name:string, taskWork:TaskWork) => {
  return http({
    method: 'post',
    url: '/flow/saveTemplate',
    data: {name: name, taskWork: taskWork}
  })
}

/**
 * 获取模版数据
 */
export const getTemplate = (name:string) => {
  return http<TaskWork>({
    method: 'post',
    url: '/flow/getTemplate',
    data: {name: name}
  })
}

/**
 * 删除模版
 */
export const deleteTemplate = (name:string) => {
  return http({
    method: 'post',
    url: '/flow/deleteTemplate',
    data: {name: name}
  })
}

export const historyList = (taskId:string) => {
  return http<FlowHistory[]>({
    method: 'post',
    url: '/flow/historyList',
    data: {taskId: taskId}
  })
}

export const historyLog = (taskId:string, batchId:number) => {
  return http<string[]>({
    method: 'post',
    url: '/flow/historyLog',
    data: {taskId: taskId, batchId: batchId}
  })
}